<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>DLC Search Engine: src/main/java/com/utn/searchengine/StopWordMap.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">DLC Search Engine
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">src/main/java/com/utn/searchengine/StopWordMap.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_stop_word_map_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="keyword">package </span>com.utn.searchengine;
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="keyword">import</span> java.io.BufferedReader;
<a name="l00004"></a>00004 <span class="keyword">import</span> java.io.DataInputStream;
<a name="l00005"></a>00005 <span class="keyword">import</span> java.io.File;
<a name="l00006"></a>00006 <span class="keyword">import</span> java.io.FileInputStream;
<a name="l00007"></a>00007 <span class="keyword">import</span> java.io.InputStreamReader;
<a name="l00008"></a>00008 <span class="keyword">import</span> java.util.HashMap;
<a name="l00009"></a>00009 
<a name="l00015"></a><a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html">00015</a> <span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">class </span><a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html">StopWordMap</a> {
<a name="l00016"></a>00016 
<a name="l00024"></a>00024     <span class="keyword">private</span> <span class="keyword">static</span> File stopWordFile = null;
<a name="l00025"></a>00025     <span class="comment">// HashMap que contiene las stop words que no seran indexadas</span>
<a name="l00026"></a>00026     <span class="keyword">private</span> <span class="keyword">static</span> HashMap stopWordMap = <span class="keyword">new</span> HashMap();
<a name="l00027"></a>00027 
<a name="l00028"></a>00028     <span class="comment">// Añade una nueva stop word al HashMap</span>
<a name="l00029"></a>00029     <span class="keyword">private</span> <span class="keyword">static</span> <span class="keywordtype">void</span> addStopWord(String stopWordString) {
<a name="l00030"></a>00030         stopWordMap.put(stopWordString.hashCode(), stopWordString);
<a name="l00031"></a>00031     }
<a name="l00032"></a>00032 
<a name="l00039"></a><a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#a34c8318401485007e2d53c5e9c644e3a">00039</a>     <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">boolean</span> <a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#a34c8318401485007e2d53c5e9c644e3a">readStopWordList</a>() {
<a name="l00040"></a>00040         <span class="keywordflow">if</span> (stopWordFile == null) {
<a name="l00041"></a>00041             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00042"></a>00042         }
<a name="l00043"></a>00043         <span class="keywordflow">try</span> {
<a name="l00044"></a>00044             <span class="comment">//Creo los flujos y encapsulo</span>
<a name="l00045"></a>00045             FileInputStream stopISWordFile = <span class="keyword">new</span> FileInputStream(stopWordFile);
<a name="l00046"></a>00046             DataInputStream dataInputStreamStopWordFile =
<a name="l00047"></a>00047                     <span class="keyword">new</span> DataInputStream(stopISWordFile);
<a name="l00048"></a>00048             BufferedReader bufferReaderStreamStopWordFile =
<a name="l00049"></a>00049                     <span class="keyword">new</span> BufferedReader(<span class="keyword">new</span> InputStreamReader(dataInputStreamStopWordFile));
<a name="l00050"></a>00050             String stopWordLine;
<a name="l00051"></a>00051             <span class="comment">//Leo cada Linea del archivo, cada linea es una palabra</span>
<a name="l00052"></a>00052             <span class="comment">//El archivo debe tener una estructura de una palabra por linea</span>
<a name="l00053"></a>00053             <span class="keywordflow">while</span> ((stopWordLine = bufferReaderStreamStopWordFile.readLine()) != null) {
<a name="l00054"></a>00054                 <span class="comment">//Muestro Las Stop Word y las añado</span>
<a name="l00055"></a>00055                 <span class="comment">//  System.out.println (stopWordLine);</span>
<a name="l00056"></a>00056                 addStopWord(stopWordLine);
<a name="l00057"></a>00057             }
<a name="l00058"></a>00058             <span class="comment">//Cierro el flujo</span>
<a name="l00059"></a>00059             bufferReaderStreamStopWordFile.close();
<a name="l00060"></a>00060         } <span class="keywordflow">catch</span> (Exception e) {
<a name="l00061"></a>00061             System.out.println(<span class="stringliteral">&quot;El archivo no se encuentra, hasta las manos!&quot;</span>);
<a name="l00062"></a>00062         }
<a name="l00063"></a>00063         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00064"></a>00064     }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066     <span class="comment">// Traigo el hashMap con todo su contenido</span>
<a name="l00067"></a><a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#ab9b95bca867332eb5e23895911e8cab1">00067</a>     <span class="keyword">public</span> <span class="keyword">static</span> HashMap <a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#ab9b95bca867332eb5e23895911e8cab1">getStopWordMap</a>() {
<a name="l00068"></a>00068         <span class="keywordflow">return</span> stopWordMap;
<a name="l00069"></a>00069     }
<a name="l00070"></a>00070 
<a name="l00078"></a><a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#a5751b256e98e75f85f2c029e8e070d87">00078</a>     <span class="keyword">public</span> <span class="keyword">static</span> File <a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#a5751b256e98e75f85f2c029e8e070d87">stopWordIdiomDocumentFinder</a>(<span class="keywordtype">int</span> selectedIdiom) {
<a name="l00079"></a>00079         <span class="comment">// 0=ingles</span>
<a name="l00080"></a>00080         <span class="comment">// 1=español</span>
<a name="l00081"></a>00081         <span class="comment">// ir agregando en funcion de las ganas.</span>
<a name="l00082"></a>00082 
<a name="l00083"></a>00083         <span class="keywordflow">switch</span> (selectedIdiom) {
<a name="l00084"></a>00084             <span class="keywordflow">case</span> 0: {
<a name="l00085"></a>00085                 stopWordFile = <span class="keyword">new</span> File(<span class="stringliteral">&quot;D:\\Projects\\temp\\Branch01\\SearchEngine\\src\\main\\resources\\TestDocuments\\stopWordsENG.txt&quot;</span>);
<a name="l00086"></a>00086                 <span class="keywordflow">break</span>;
<a name="l00087"></a>00087             }
<a name="l00088"></a>00088             <span class="keywordflow">case</span> 1: {
<a name="l00089"></a>00089                 stopWordFile = <span class="keyword">new</span> File(<span class="stringliteral">&quot;G:\\Julian Peker\\DLC final\\Branch01\\SearchEngine\\src\\main\\resources\\TestDocuments\\stopwordsSPA.txt&quot;</span>);
<a name="l00090"></a>00090                 <span class="keywordflow">break</span>;
<a name="l00091"></a>00091             }
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         }
<a name="l00094"></a>00094         <span class="comment">// Devuelvo en funcion del idioma elegido</span>
<a name="l00095"></a>00095         <span class="keywordflow">return</span> stopWordFile;
<a name="l00096"></a>00096     }
<a name="l00097"></a>00097     <span class="comment">//Verifica si la Word esta contenida en el HashMap de stopWords</span>
<a name="l00098"></a>00098 
<a name="l00099"></a><a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#a6cd1b227a3e35ec13cb2cf20690708dd">00099</a>     <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">boolean</span> <a class="code" href="classcom_1_1utn_1_1searchengine_1_1_stop_word_map.html#a6cd1b227a3e35ec13cb2cf20690708dd">isStopWord</a>(String word) {
<a name="l00100"></a>00100         <span class="keywordflow">if</span> (stopWordMap.containsValue(word)) {
<a name="l00101"></a>00101             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00102"></a>00102         }
<a name="l00103"></a>00103         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00104"></a>00104     }
<a name="l00105"></a>00105 }
</pre></div></div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Thu Feb 16 2012 02:45:40 for DLC Search Engine by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
